<?php
class Common_Service_Mail {
	private static $summary = array();
	public static function sendMail($to_mail){

		// 附件
		$stockOk = self::csvProductStockMake();
		$orderOk = self::csvOrdersMake();
		
		$arr = array(
				"product" => $stockOk,
				"order" => $orderOk
		);
		
		$mail = Cff::setupMail();
		
		$mail->setBodyText(date("Y-m-d") . "订单与库存记录");
		// 		$mail->setFrom('somebody@example.com', "三态CFF");
		$mail->addTo($to_mail, date("Y-m-d") . "订单与库存记录");
		$mail->setSubject(date("Y-m-d") . "订单与库存记录");
		
		foreach ( $arr as $k => $v ) {
			$at = $mail->createAttachment($v);
			$at->type = 'application/vnd.ms-excel';
			$at->disposition = Zend_Mime::DISPOSITION_INLINE;
			$at->encoding = Zend_Mime::ENCODING_8BIT;
			$at->filename = $k . '.csv';
		}
		
		$mail->send();
	}
	
	public static function csvProductStockMake(){
		$list = Product_Service_ProductStocket::getByCondition(array(), "*", "", 0, 1);
		$contents = "";
		$line = "";
		if (count($list) > 0) {
			foreach ( $list[0] as $k => $v ) {
				$line .= "$k,";
			}
			$line = trim($line, ",");
			$line .= "\n";
		}
		$contents .= $line;
		foreach ( $list as $key => $val ) {
			$line = "";
			foreach ( $val as $k => $v ) {
				$v = preg_replace("/,/", " ", $v);
				$line .= "$v,";
			}
			$line = trim($line, ",");
			$line .= "\n";
			$contents .= $line;
		}
		$flag = file_put_contents(APPLICATION_PATH . "/../data/" . date("Y-m-d") . "_product.csv", $contents);
		return $contents;
	}
	
	public static function csvOrdersMake(){
		$date_from = date('Y-m-d', strtotime("-1 day")) . " 22:00:00";
		$date_to = date('Y-m-d') . " 22:00:00";
		
		$list = Order_Service_Order::getByCondition(array(
				"date_from" => $date_from,
				"date_to" => $date_to
		), "*", "", 0, 1);
		$contents = "";
		$line = "";
		if (count($list) > 0) {
			foreach ( $list[0] as $k => $v ) {
				$line .= "$k,";
			}
			$line = trim($line, ",");
			$line .= "\n";
		}
		$contents .= $line;
		foreach ( $list as $key => $val ) {
			$line = "";
			foreach ( $val as $k => $v ) {
				$v = preg_replace("/,/", " ", $v);
				$line .= "$v,";
			}
			$line = trim($line, ",");
			$line .= "\n";
			$contents .= $line;
		}
		$flag = file_put_contents(APPLICATION_PATH . "/../data/" . date("Y-m-d") . "_order.csv", $contents);
		return $contents;
	}
	//销售出库
	private static function csvOrdersProductsMake(){
		$date_from = date('Y-m-d', strtotime("-1 day")) . " 05:00:00";
		$date_to = date('Y-m-d') . " 05:00:00";
		
		$allContent = array();
		$con = array(
				"ship_date_from" => $date_from,
				"ship_date_to" => $date_to,
				"process_status" => 5
		);
		$map = array(
				'orders_code' => "订单号",
				'customer_order_code' => "客户参考号",
				'shipping_method' => "物流方式",
				'add_time' => "创建时间",
				'ship_date' => "出货时间",
				'product_id' => "产品ID",
				'product_sku' => "SKU",
				'op_quantity' => "产品数量",
				'op_weight' => "产品重量",
				'weight' => "订单重量",
		);
		
		$selCol = array(
				'orders_code',
				'customer_order_code',
				'shipping_method',
				'add_time',
				'ship_date'
		);
		$orders = Order_Service_Order::getByCondition($con, $selCol, "", 0, 1);
		$allProducts = array();
		$allWeight = 0;
		foreach ( $orders as $k => $v ) {
			$innCon = array(
					"orders_code" => $v['orders_code']
			);
			$selCol = array(
					'product_id',
					'product_sku',
					'op_quantity',
					'op_weight'
			);
			$products = Order_Service_Product::getByCondition($innCon, $selCol, "", 0, 1);
			$orderWeight = 0;
			foreach ( $products as $val ) {
				$orderWeight += $val['op_quantity'] * $val['op_weight'];
				if (isset($allProducts[$val['product_id']])) {
					$allProducts[$val['product_id'] . "________" . $val['product_sku']] += $val['op_quantity'];
				} else {
					$allProducts[$val['product_id'] . "________" . $val['product_sku']] = $val['op_quantity'];
				}
			}
			$orders[$k]['weight'] = $orderWeight;
			$orders[$k]['products'] = $products;
			$allWeight+=$orderWeight;
		}
		
		$contents = "";
		$line = "";
		if (count($orders) > 0) {
			foreach ( $orders[0] as $k => $v ) {
				if ($k == "products") {
					continue;
				}
				$line .= $map[$k].",";
			}
			$line .= "出库类型,";
			$line = trim($line, ",");
			$line .= "\n";
			
			$contents .= $line;
			foreach ( $orders as $key => $val ) {
				
				$line = "";
				foreach ( $val as $k => $v ) {
					if ($k == "products") {
						continue;
					}
					$v = preg_replace("/,/", " ", $v);
					$line .= "$v,";
				}
				$line .= "销售出库,";
				$line = trim($line, ",");
				$line .= "\n";
				$contents .= $line;
			}
		}
		$contents = iconv("UTF-8", "GB2312", $contents);
		$allContent['销售出库单'] = $contents;
		$flag = file_put_contents(APPLICATION_PATH . "/../data/" . date("Y-m-d") .  iconv("UTF-8", "GB2312", "_o.csv"), $contents);
		
		$contents = "";
		$line = "";
		$productCount = 0;
		if (count($allProducts) > 0) {
			
			$line .= "SKU,";
			$line .= "产品数量,";
			$line .= "出库类型,";
			$line = trim($line, ",");
			$line .= "\n";
			
			$contents .= $line;
			foreach ( $allProducts as $k => $v ) {
				$productCount+=$v;
				$line = "";
				$sku = preg_replace("/^[0-9]+/", "", $k);
				$sku = preg_replace("/^_+/", "", $sku);
				$line .= $sku . ",";
				$v = preg_replace("/,/", " ", $v);
				$line .= "$v,";
				
				$line .= "销售出库,";
				$line = trim($line, ",");
				$line .= "\n";
				$contents .= $line;
			}
		}
		
		$contents = iconv("UTF-8", "GB2312", $contents);
		
		$allContent['销售出库产品'] = $contents;
		$flag = file_put_contents(APPLICATION_PATH . "/../data/" . date("Y-m-d") . iconv("UTF-8", "GB2312", "_op.csv"), $contents);
		
		self::$summary['normalOrderCount'] = count($orders);
		self::$summary['normalProductCount'] = $productCount;
		self::$summary['normalProductCount'] = $productCount;
		self::$summary['normalWeightCount'] = $allWeight;
		
		return $allContent;
	}
	//领用/借用
	public static function csvCeiveOrdersProductsMake(){
		$date_from = date('Y-m-d', strtotime("-1 day")) . " 05:00:00";
		$date_to = date('Y-m-d') . " 05:00:00";
	
		$allContent = array();
		$con = array(
				"cu_create_date_from" => $date_from,
				"cu_create_date_to" => $date_to,
		);
		$map = array(
				'cu_id' => "主键",
				'cu_code' => "领用/借用号",
				'customer_order_code' => "客户参考号",
				'shipping_method' => "物流方式",
				'add_time' => "创建时间",
				'ship_date' => "出货时间",
				'product_id' => "产品ID",
				'product_sku' => "SKU",
				'cui_get_quantity' => "领用/借用数量",
				'cui_back_quantity' => "归还数量",
				'weight' => "订单重量",
				'cu_create_date'=>"领用/借用时间",
				'cu_handback_date'=>"归还时间",
				'cu_status'=>"状态",
				'cu_username'=>"借/领用人",
				'cu_use'=>"用途",
				'type'=>"领用、借用",
		);
	
		$selCol = array(
				'cu_id',
				'cu_code',
				'cu_create_date',
				'cu_handback_date',
				'cu_status',
				'cu_username',
				'cu_use',
		);
		$orders = Ceiveuse_Service_Ceiveuse::getByCondition($con, $selCol, "", 0, 1);
		$allProducts = array();
		$allWeight = 0;
		foreach ( $orders as $k => $v ) {
			if($v['cu_status']==1&&$v['cu_handback_date']=="0000-00-00 00:00:00"){
				$orders[$k]['type'] = "领用";
				$type = 1;
			}else{
				$orders[$k]['type'] = "借用";
				$type = 2;
			}			
			$innCon = array(
					"cu_id" => $v['cu_id']
			);
			$selCol = array(
					'product_id',
					'cui_get_quantity',
					'cui_back_quantity',
					'cui_create_date'
			);
			$products = Ceiveuse_Service_CeiveuseItem::getByCondition($innCon, $selCol, "", 0, 1);
			$orderWeight = 0;
			foreach ( $products as $key=> $val ) {
				$product = Product_Service_Product::getByProductId($val['product_id']);
				$products[$key]['product_sku'] = $product['product_sku'];
				$orderWeight += $val['cui_get_quantity'] * $product['product_weight'];
// 				if (isset($allProducts[$val['product_id']])) {//sku合并
// 					$allProducts[$val['product_id'] . "________" . $product['product_sku']] += $val['cui_get_quantity'];
// 				} else {
// 					$allProducts[$val['product_id'] . "________" . $product['product_sku']] = $val['cui_get_quantity'];
// 				}
				//sku不合并
				$allProducts[] = $orders[$k]['type']."________".$product['product_sku']."________".$val['cui_get_quantity']."________".$type;
			}
			$orders[$k]['weight'] = $orderWeight;
			$orders[$k]['products'] = $products;
			$allWeight+=$orderWeight;
		}
	
		$contents = "";
		$line = "";
		if (count($orders) > 0) {
			foreach ( $orders[0] as $k => $v ) {
				if ($k == "products") {
					continue;
				}
				if ($k == "cu_status") {
					continue;
				}
				if ($k == "cu_handback_date") {
					continue;
				}
				$line .= $map[$k].",";
			}
			
			$line = trim($line, ",");
			$line .= "\n";
				
			$contents .= $line;
			foreach ( $orders as $key => $val ) {
	
				$line = "";
				foreach ( $val as $k => $v ) {
					if ($k == "products") {
						continue;
					}
					if ($k == "cu_status") {
						continue;
					}
					
					if ($k == "cu_handback_date") {
						continue;
					}
					$v = preg_replace("/,/", " ", $v);
					$line .= "$v,";
				}
				$line = trim($line, ",");
				$line .= "\n";
				$contents .= $line;
			}
		}else{
			
			$line = "无记录,";
			$line = trim($line, ",");
			$line .= "\n";
			
			$contents .= $line;
		}
		$contents = iconv("UTF-8", "GB2312", $contents);
		$allContent['领用、借用单'] = $contents;
		$flag = file_put_contents(APPLICATION_PATH . "/../data/" . date("Y-m-d") . iconv("UTF-8", "GB2312", "_cu.csv"), $contents);
	
		$contents = "";
		$line = "";
		$productCount=0;
		$linCount=0;
		$jieCount=0;
		if (count($allProducts) > 0) {
				
			$line .= "SKU,";
			$line .= "产品数量,";
			$line .= "出库类型,";
			$line = trim($line, ",");
			$line .= "\n";
				
			$contents .= $line;
// 			foreach ( $allProducts as $k => $v ) {//sku合并
// 				$productCount+=$v;
// 				$line = "";
// 				$sku = preg_replace("/^[0-9]+/", "", $k);
// 				$sku = preg_replace("/^_+/", "", $sku);
// 				$line .= $sku . ",";
// 				$v = preg_replace("/,/", " ", $v);
// 				$line .= "$v,";
	
// 				$line .= "领用、借用出库,";
// 				$line = trim($line, ",");
// 				$line .= "\n";
// 				$contents .= $line;
// 			}
// 			sku不合并
			foreach ( $allProducts as $k => $v ) {
				$line = "";
				$v = explode("________", $v);	
				$productCount+=$v[2];
				if($v[3]==1){
					$linCount+=$v[2];
				}else if($v[3]==2){
					$jieCount+=$v[2];
				}			
				$line .= "{$v[1]},";
				$line .= "{$v[2]},";
				$line .= "{$v[0]},";
				$line = trim($line, ",");
				$line .= "\n";
				$contents .= $line;
			}
		}else{			
			$line = "无记录,";
			$line = trim($line, ",");
			$line .= "\n";
			
			$contents .= $line;
		}	
		
		$contents = iconv("UTF-8", "GB2312", $contents);
	
		$allContent['领用、借用产品'] = $contents;
		$flag = file_put_contents(APPLICATION_PATH . "/../data/" . date("Y-m-d") . iconv("UTF-8", "GB2312", "_cui.csv"), $contents);
		
		self::$summary['specialOrderCount'] = count($orders);
		self::$summary['specialProductCount'] = $productCount;
		self::$summary['linProductCount'] = $linCount;
		self::$summary['jieProductCount'] = $jieCount;
		self::$summary['specialWeightCount'] = $allWeight;
		
		return $allContent;
	}
	
	public static function sendOrderProductMail($to_mail){
		
		$date_from = date('Y-m-d', strtotime("-1 day")) . " 05:00:00";
		$date_to = date('Y-m-d') . " 05:00:00";
		
		// 附件  销售出库
		$arr = self::csvOrdersProductsMake();
		
		// 附件 领用、借用
		$arr1 = self::csvCeiveOrdersProductsMake();
// 		print_r(self::$summary);
// 		exit;
		$mail = Cff::setupMail();
		$summary = self::$summary;
// 		$summaryContent = "<br/>销售出库{$summary['normalOrderCount']}单,销售出库共计产品{$summary['normalProductCount']} 个,销售出库共计产品重量{$summary['normalWeightCount']}克，<br/>
// 		领用、借用{$summary['specialOrderCount']}单，领用、借用共计产品{$summary['specialProductCount']} 个,领用、借用共计产品重量{$summary['specialWeightCount']}克";
		$summaryContent = <<<EOF
		<br />
	<br />
	<br />销售出库
	<strong
		style='color: red; padding: 0 5px; font-weight: bold; font-size: 14px;'>{$summary['normalOrderCount']}</strong>单,销售出库共计产品
	<strong
		style='color: red; padding: 0 5px; font-weight: bold; font-size: 14px;'>{$summary['normalProductCount']}</strong>
	个,销售出库共计产品重量
	<strong
		style='color: red; padding: 0 5px; font-weight: bold; font-size: 14px;'>{$summary['normalWeightCount']}</strong>克，
	<br /> 领用、借用
	<strong
		style='color: red; padding: 0 5px; font-weight: bold; font-size: 14px;'>{$summary['specialOrderCount']}</strong>单，领用、借用共计产品
	<strong
		style='color: red; padding: 0 5px; font-weight: bold; font-size: 14px;'>{$summary['specialProductCount']}</strong>
	个,其中领用<strong
		style='color: red; padding: 0 5px; font-weight: bold; font-size: 14px;'>{$summary['linProductCount']}</strong>
	个,借用<strong
		style='color: red; padding: 0 5px; font-weight: bold; font-size: 14px;'>{$summary['jieProductCount']}</strong>
	个,领用、借用共计产品重量
	<strong
		style='color: red; padding: 0 5px; font-weight: bold; font-size: 14px;'>{$summary['specialWeightCount']}</strong>克;
EOF;
		$mail->setBodyHtml($date_from . "至{$date_to}出货订单与出货产品报表".$summaryContent);
		// 		$mail->setFrom('cff@example.com', "三态CFF");
		$mail->addTo($to_mail, $date_from . "至{$date_to}出货订单与出货产品报表");
		$mail->setSubject($date_from . "至{$date_to}出货订单与出货产品报表");
		
		foreach ( $arr as $k => $v ) {
			$at = $mail->createAttachment($v);
			$at->type = 'application/vnd.ms-excel';
			$at->disposition = Zend_Mime::DISPOSITION_INLINE;
			$at->encoding = Zend_Mime::ENCODING_8BIT;
			$at->filename = iconv("UTF-8", "GB2312", $date_from . "至{$date_to} ".$k) . '.csv';
		}
		foreach ( $arr1 as $k => $v ) {
			$at = $mail->createAttachment($v);
			$at->type = 'application/vnd.ms-excel';
			$at->disposition = Zend_Mime::DISPOSITION_INLINE;
			$at->encoding = Zend_Mime::ENCODING_8BIT;
			$at->filename = iconv("UTF-8", "GB2312", $date_from . "至{$date_to} ".$k) . '.csv';
		}		
		
		$mail->send();
	}
	
	public static function testMail($to_mail){
		$mail = new Zend_Mail("UTF-8");
		$html = <<<EOF
<img src="http://ctrip.otrip.in/uARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROBAYOURMKCx4NDx4MNggJVlFIFQoWARMaNQANXFRNGgsJCzkaCAMPVFhSXlxeV1NcVVdHGxkMGwgJVgoaFQYWDwUMTAwEAAQHVFxfX15bWF9fUSkQHEUKAQpJBQEMHgsABwgJVgoaFQYWQAAKElhbUVxZWVpWWQ==" border="0" width="0"><div><includetail><table align="center" cellpadding="0" cellspacing="0" width="700">
<tbody><tr>
<td style="FONT-FAMILY: '微软雅黑'; FONT-SIZE: 12px" width="650">如果无法看到邮件完整内容，请<a href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWQ==" target="_blank">点击此处</a>查看</td></tr></tbody></table>
<table id="__01" align="center" border="0" cellpadding="0" cellspacing="0" width="700">
<tbody><tr>
<td><a href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWQ==" target="_blank"><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_01.jpg" border="0" height="621" width="233"></a></td>
<td colspan="2"><a href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWQ==" target="_blank"><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_02.jpg" border="0" height="621" width="234"></a></td>
<td><a href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWQ==" target="_blank"><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_03.jpg" border="0" height="621" width="233"></a></td></tr></tbody></table>
<table id="__01" align="center" border="0" cellpadding="0" cellspacing="0" width="700">
<tbody><tr>
<td colspan="3" background="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_04.jpg" height="22" valign="center" width="378"><span style="COLOR: #880306; FONT-SIZE: 17px; FONT-WEIGHT: bold">　　　　　　　　　　　　1652893611
</span>
</td>
<td colspan="3" background="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_05.jpg" height="22" valign="center" width="322"><span style="COLOR: #880306; FONT-SIZE: 17px; FONT-WEIGHT: bold">　　　 0109</span></td></tr></tbody></table>
<table id="__01" align="center" border="0" cellpadding="0" cellspacing="0" width="700">
<tbody><tr>
<td colspan="4"><a href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWQ==" target="_blank"><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/ctrip_06.jpg" border="0" height="307" width="700"></a></td></tr>
<tr>
<td><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/%B7%D6%B8%F4%B7%FB.gif" height="1" width="233"></td>
<td><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/%B7%D6%B8%F4%B7%FB.gif" height="1" width="145"></td>
<td><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/%B7%D6%B8%F4%B7%FB.gif" height="1" width="89"></td>
<td><img src="http://gz.001fc.cn/yuwen/ctrip04.13a/images/%B7%D6%B8%F4%B7%FB.gif" height="1" width="233"></td></tr></tbody></table>
<table style="BORDER-TOP: #072669 1px solid" align="center" border="0" cellpadding="0" cellspacing="0" width="700">
<tbody><tr>
<td style="PADDING-BOTTOM: 5px; LINE-HEIGHT: 22px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; FONT-FAMILY: 微软雅黑; COLOR: #666; FONT-SIZE: 11px; PADDING-TOP: 5px">从中国到世界，从商务旅行到休闲旅游度假，无论身处何地，携程都将帮助您获得美好的旅行体验，携手成就精彩人生旅程！
<br>我们诚挚地邀请您参加携程网特邀会员回馈奖励活动，为亲友预定同享好礼，快快行动吧！
<br>如需了解活动详情，欢迎您登录我们的活动专区(
<a style="FONT-FAMILY: 微软雅黑; COLOR: #666; TEXT-DECORATION: none" href="http://ctrip.otrip.in/vARUZG1NBSAwSHAgeRAYdEwQbRwcJQAceEUEPDQROGRlWGgICFgIAGg82AAVQU08cAh8JHBUxAw1UWEsYDAADMBIHDAtXWFpSWlxQWlRcX0gUHQ8bAAVQCB0cDh8HCgNIDwQICAFWW1ZXV1NXUFtSKRgQQwgGA0EMCQMRDwMHAAVQCB0cDh9IDwUWW1tZUF9bXV9RSRMcDVMUWA==" target="_blank">www.ctrip.com/c/jx/
</a> )谢谢您的支持！成就精彩人生旅程！
<br>携程旅行网，中国领先的旅行服务公司，服务网络覆盖国内60多个城市，为超过6000万会员提供酒店、机票、旅游度假等全面旅行服务。
</td>
</tr>
</tbody></table></includetail></div>
EOF;
		
		$mail->setBodyHtml($html, "UTF-8");
		$mail->setFrom('somebody@example.com', "html Test");
		$mail->addTo($to_mail, "html Test");
		$mail->setSubject("htmlsdfsdf Test");
		
		// //附件
		// $stockOk = self::csvProductStockMake();
		// $orderOk = self::csvOrdersMake();
		
		// $arr = array("product"=>$stockOk,"order"=>$orderOk);
		// foreach($arr as $k=>$v){
		// $at = $mail->createAttachment($v);
		// $at->type = 'application/vnd.ms-excel';
		// $at->disposition = Zend_Mime::DISPOSITION_INLINE;
		// $at->encoding = Zend_Mime::ENCODING_8BIT;
		// $at->filename = $k.'.csv';
		// }
		
		$mail->send();
	}
}